package com.webchat.search.service;

import com.webchat.common.bean.APIResponseBean;
import com.webchat.common.bean.APIResponseBeanUtil;
import com.webchat.domain.vo.response.publicaccount.ArticleBaseResponseVO;
import com.webchat.rmi.pgc.OfficialArticleClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service
public class ArticleService {


    @Autowired
    private OfficialArticleClient officialArticleClient;

    /**
     * 批量查询redis，获取文章详情缓存
     *
     * 场景：公众号详情页，一次可能查询10篇文章
     * @param articleIds
     * @return
     */
    public Map<Long, ArticleBaseResponseVO> batchGet(List<Long> articleIds) {
        APIResponseBean<Map<Long, ArticleBaseResponseVO>> responseBean = officialArticleClient.batchGet(articleIds);
        if (APIResponseBeanUtil.isOk(responseBean)) {
            return responseBean.getData();
        }
        return null;
    }

}
